package com.xiaoshuidi.cloud.module.contract.dal.mysql.contract;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoshuidi.cloud.framework.mybatis.core.mapper.BaseMapperX;
import com.xiaoshuidi.cloud.module.contract.controller.admin.contract.vo.settlement.ContractSettlementCompanyListRespVO;
import com.xiaoshuidi.cloud.module.contract.controller.admin.contract.vo.settlement.ContractSettlementGetListReqVO;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.contract.SettlementDO;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.contract.SettlementDetailDO;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.contract.SettlementExtDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 合同结算 Mapper
 *
 * @author 合房租赁
 */
@Mapper
public interface SettlementMapper extends BaseMapperX<SettlementDO> {


    IPage<SettlementExtDO> pageContractList(Page<SettlementExtDO> page,
                                            @Param("reqVO") ContractSettlementGetListReqVO reqVO);

    IPage<SettlementExtDO> pageContractBatchList(Page<SettlementExtDO> page,
                                                 @Param("reqVO") ContractSettlementGetListReqVO reqVO);

    List<SettlementExtDO> pageContractBatchList(@Param("reqVO") ContractSettlementGetListReqVO reqVO);

    List<SettlementExtDO> pageContractList(@Param("reqVO") ContractSettlementGetListReqVO reqVO);

    IPage<ContractSettlementCompanyListRespVO> pageCompanyContractList(Page<ContractSettlementCompanyListRespVO> page
            , @Param("reqVO") ContractSettlementGetListReqVO reqVO);

    @Select("select id from contract_settlement " +
            " where parent_settlement_id = #{id}")
    List<Long> selectSettlementIdByParentId(@Param("id") Long id);

    void updateClearedStatusByIds(@Param("ids") List<Long> ids);

    List<SettlementDetailDO> getSettlementDetailCount(@Param("id")Long id);

    void deleteDetailsByContractId(Long contractId);
}
